package VLine

type Loop interface {
	Next() interface{}
	HasNext() bool
}

type LoopString struct {
	index int
	value string
}

func LoopStringNew(value string) *LoopString {
	return &LoopString{0, value}
}

func (loopString *LoopString) Next() interface{} {
	loopString.index++
	return string(loopString.value[loopString.index-1])
}

func (loopString *LoopString) HasNext() bool {
	return loopString.index < len(loopString.value)
}

type LoopTable struct {
}

type LoopRange struct {
	begin int
	end   int
	step  int
	rise  bool
}

func (loopRange *LoopRange) Next() interface{} {
	var value = loopRange.begin
	loopRange.begin += loopRange.step
	return value
}

func (loopRange *LoopRange) HasNext() bool {
	if loopRange.rise {
		return loopRange.begin <= loopRange.end
	}
	return loopRange.begin >= loopRange.end
}
